import requests
import json
import random

class data_compare():
    '''数据一致性对比'''

    def __init__(self):
        self.headers = {"Content-Type": "application/json", "charset": "UTF-8"}

    def testWebLogIn(self):
        url = "https://ec-test.casstime.com/passport/login"
        cellphoneList = ["13", "14", "15", "16", "17", "18", "19"]
        numList = '0123456789'
        params = {
            "logintype": "PASSWORD",
            "username": "ksmgg",
            "password": "Cass1713",
            "cellphone": random.choice(cellphoneList) + "".join(random.choice(numList) for i in range(9)),
            "verifycode": ""
        }
        s = requests.session()
        r1 = s.post(url, data=params, headers={"Content-Type": "application/x-www-form-urlencoded"})
        print(r1.text)
        print("执行成功！")
        return s

    def test01_best_Level_Comparison_of_Platforms(self):
        url = "https://ec-test.casstime.com/sellerMgr/serviceAnalysis/performance"
        params = {
            "month":"201908",
            "date":"data",
            "area":"COUNTRYWIDE"
        }
        s = self.testWebLogIn()
        response = s.get(url,params=params, headers=self.headers)
        print("http状态码：", response.status_code)
        print("响应结果：", response.json())
        assert response.status_code == 200

    def test_09(self):
        url = "https://ec-test.casstime.com/systemMgr/accountapplication/publish"
        params = {
            "cassAideId": "CQDA123",
            "id":"",
            "venId": "",
            "companyId": "CQDA0001",
            "userName": "毛人凤",
            "userAccount": "mrfsam",
            "userInitialPassword": "123123",
            "userPhone": "13200320001"
        }
        s = self.testWebLogIn()
        response = s.post(url, data=json.dumps(params), headers=self.headers)
        print(response.text)
        assert response.status_code == 200



if __name__ == "__main__":
    test01 = data_compare()
    # test01.test01_best_Level_Comparison_of_Platforms()
    test01.test_09()